<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    //
    public function Index()
    {
        return 'xxxx';
    }

    public function login()
    {
        return 'login';
    }

    public function register(Request $request)
    {
        $user = new User();
//        用户名为游客加默认生成
        $user->name = 'xxx';
        $user->name = $request['email'];
//        password需要用slat+md5加密
        $user->password = $request['password'];
        $user->save();
        $result['code'] = 0;
        $result['msg'] = 'register success';
        return json_encode($result);
    }
}
